using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Data;
using System.Data.SqlClient;
using System.Xml;
using System.Reflection;
using Microsoft.Win32;
using System.IO;
using Srvtools;
using System.Security;
using System.Security.Permissions;

namespace sPpoPr1
{
    /// <summary>
    /// Summary description for Component.
    /// </summary>
    public class Component : DataModule
    {
        private UpdateComponent ucMaster;
        private ServiceManager serviceManager;
        private InfoCommand Master;
        private InfoCommand Detail;
        private InfoDataSource idsRelation;
        private UpdateComponent ucDetail;
        private InfoConnection infoConnection;
        private AutoNumber NO_PO;
        private InfoCommand ORD_D;
        private InfoTransaction trQT_QTY;
        private InfoCommand MasterView;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components;

        public Component(System.ComponentModel.IContainer container)
        {
            ///
            /// Required for Windows.Forms Class Composition Designer support
            ///
            container.Add(this);
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        public Component()
        {
            ///
            /// This call is required by the Windows.Forms Designer.
            ///
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
        }

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
        public string GetFixed()
        {
            return string.Format("PR{0:yyMM}", DateTime.Now.Date);
        }

        public object GetNOORD()
        {
            return ucMaster.GetFieldCurrentValue("NO_ORDER").ToString();
        }

        #region Component Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.components = new System.ComponentModel.Container();
            Srvtools.KeyItem keyItem1 = new Srvtools.KeyItem();
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Component));
            Srvtools.KeyItem keyItem2 = new Srvtools.KeyItem();
            Srvtools.KeyItem keyItem3 = new Srvtools.KeyItem();
            Srvtools.ColumnItem columnItem1 = new Srvtools.ColumnItem();
            Srvtools.ColumnItem columnItem2 = new Srvtools.ColumnItem();
            Srvtools.KeyItem keyItem4 = new Srvtools.KeyItem();
            Srvtools.KeyItem keyItem5 = new Srvtools.KeyItem();
            Srvtools.Transaction transaction1 = new Srvtools.Transaction();
            Srvtools.TransField transField1 = new Srvtools.TransField();
            Srvtools.TransKeyField transKeyField1 = new Srvtools.TransKeyField();
            Srvtools.TransKeyField transKeyField2 = new Srvtools.TransKeyField();
            Srvtools.KeyItem keyItem6 = new Srvtools.KeyItem();
            this.ucMaster = new Srvtools.UpdateComponent(this.components);
            this.Master = new Srvtools.InfoCommand(this.components);
            this.infoConnection = new Srvtools.InfoConnection();
            this.serviceManager = new Srvtools.ServiceManager(this.components);
            this.Detail = new Srvtools.InfoCommand(this.components);
            this.idsRelation = new Srvtools.InfoDataSource(this.components);
            this.ucDetail = new Srvtools.UpdateComponent(this.components);
            this.NO_PO = new Srvtools.AutoNumber(this.components);
            this.ORD_D = new Srvtools.InfoCommand(this.components);
            this.trQT_QTY = new Srvtools.InfoTransaction(this.components);
            this.MasterView = new Srvtools.InfoCommand(this.components);
            ((System.ComponentModel.ISupportInitialize)(this.Master)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.infoConnection)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.Detail)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.ORD_D)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.MasterView)).BeginInit();
            // 
            // ucMaster
            // 
            this.ucMaster.AutoTrans = true;
            this.ucMaster.ExceptJoin = false;
            this.ucMaster.LogInfo = null;
            this.ucMaster.Name = "ucMaster";
            this.ucMaster.SelectCmd = this.Master;
            this.ucMaster.ServerModify = true;
            this.ucMaster.ServerModifyGetMax = false;
            this.ucMaster.TransIsolationLevel = System.Data.IsolationLevel.ReadCommitted;
            this.ucMaster.WhereMode = Srvtools.WhereModeType.Keyfields;
            // 
            // Master
            // 
            this.Master.CommandText = "select [PPO_PR1_M].* from [PPO_PR1_M] where CD_PO=\'1\'";
            this.Master.CommandTimeout = 30;
            this.Master.CommandType = System.Data.CommandType.Text;
            this.Master.EEPAlias = null;
            this.Master.InfoConnection = this.infoConnection;
            keyItem1.KeyName = "NO_PR";
            this.Master.KeyFields.Add(keyItem1);
            this.Master.Name = "Master";
            this.Master.NotificationAutoEnlist = false;
            this.Master.SecExcept = null;
            this.Master.SecFieldName = "";
            this.Master.SecStyle = Srvtools.SecurityStyle.ssByNone;
            this.Master.SelectTop = 0;
            this.Master.SiteControl = false;
            this.Master.SiteFieldName = "";
            this.Master.Transaction = null;
            this.Master.UpdatedRowSource = System.Data.UpdateRowSource.Both;
            // 
            // infoConnection
            // 
            this.infoConnection.ConnectionType = Srvtools.ConnectionType.SqlClient;
            this.infoConnection.EEPAlias = "ERPS";
            // 
            // Detail
            // 
            this.Detail.CommandText = resources.GetString("Detail.CommandText");
            this.Detail.CommandTimeout = 30;
            this.Detail.CommandType = System.Data.CommandType.Text;
            this.Detail.EEPAlias = null;
            this.Detail.InfoConnection = this.infoConnection;
            keyItem2.KeyName = "NO_PR";
            keyItem3.KeyName = "CN_SEQ";
            this.Detail.KeyFields.Add(keyItem2);
            this.Detail.KeyFields.Add(keyItem3);
            this.Detail.Name = "Detail";
            this.Detail.NotificationAutoEnlist = false;
            this.Detail.SecExcept = null;
            this.Detail.SecFieldName = "";
            this.Detail.SecStyle = Srvtools.SecurityStyle.ssByNone;
            this.Detail.SelectTop = 0;
            this.Detail.SiteControl = false;
            this.Detail.SiteFieldName = "";
            this.Detail.Transaction = null;
            this.Detail.UpdatedRowSource = System.Data.UpdateRowSource.Both;
            // 
            // idsRelation
            // 
            this.idsRelation.Detail = this.Detail;
            columnItem1.FieldName = "NO_PR";
            this.idsRelation.DetailColumns.Add(columnItem1);
            this.idsRelation.DynamicTableName = false;
            this.idsRelation.Master = this.Master;
            columnItem2.FieldName = "NO_PR";
            this.idsRelation.MasterColumns.Add(columnItem2);
            // 
            // ucDetail
            // 
            this.ucDetail.AutoTrans = true;
            this.ucDetail.ExceptJoin = false;
            this.ucDetail.LogInfo = null;
            this.ucDetail.Name = "ucDetail";
            this.ucDetail.SelectCmd = this.Detail;
            this.ucDetail.ServerModify = true;
            this.ucDetail.ServerModifyGetMax = false;
            this.ucDetail.TransIsolationLevel = System.Data.IsolationLevel.ReadCommitted;
            this.ucDetail.WhereMode = Srvtools.WhereModeType.Keyfields;
            // 
            // NO_PO
            // 
            this.NO_PO.Active = true;
            this.NO_PO.AutoNoID = "NO_PO";
            this.NO_PO.Description = null;
            this.NO_PO.GetFixed = "GetFixed()";
            this.NO_PO.isNumFill = false;
            this.NO_PO.Name = "NO_PO";
            this.NO_PO.Number = null;
            this.NO_PO.NumDig = 4;
            this.NO_PO.OldVersion = false;
            this.NO_PO.OverFlow = true;
            this.NO_PO.StartValue = 1;
            this.NO_PO.Step = 1;
            this.NO_PO.TargetColumn = "NO_PR";
            this.NO_PO.UpdateComp = this.ucMaster;
            // 
            // ORD_D
            // 
            this.ORD_D.CommandText = resources.GetString("ORD_D.CommandText");
            this.ORD_D.CommandTimeout = 30;
            this.ORD_D.CommandType = System.Data.CommandType.Text;
            this.ORD_D.EEPAlias = null;
            this.ORD_D.InfoConnection = this.infoConnection;
            keyItem4.KeyName = "NO_ORDER";
            keyItem5.KeyName = "CN_SEQ";
            this.ORD_D.KeyFields.Add(keyItem4);
            this.ORD_D.KeyFields.Add(keyItem5);
            this.ORD_D.Name = "ORD_D";
            this.ORD_D.NotificationAutoEnlist = false;
            this.ORD_D.SecExcept = null;
            this.ORD_D.SecFieldName = null;
            this.ORD_D.SecStyle = Srvtools.SecurityStyle.ssByNone;
            this.ORD_D.SelectTop = 0;
            this.ORD_D.SiteControl = false;
            this.ORD_D.SiteFieldName = null;
            this.ORD_D.Transaction = null;
            this.ORD_D.UpdatedRowSource = System.Data.UpdateRowSource.Both;
            // 
            // trQT_QTY
            // 
            this.trQT_QTY.Name = "trQT_QTY";
            transaction1.AutoNumber = null;
            transField1.DesField = "QT_PR_END";
            transField1.DesValue = null;
            transField1.FieldType = null;
            transField1.FieldTypeName = null;
            transField1.ReadOnly = false;
            transField1.SrcField = "QT_QTY";
            transField1.SrcGetValue = null;
            transField1.SrcValue = null;
            transField1.UpdateMode = Srvtools.UpdateMode.Inc;
            transaction1.TransFields.Add(transField1);
            transKeyField1.DesField = "NO_ORDER";
            transKeyField1.DesValue = null;
            transKeyField1.FieldType = null;
            transKeyField1.FieldTypeName = null;
            transKeyField1.ReadOnly = false;
            transKeyField1.SrcField = "NO_ORDER";
            transKeyField1.SrcGetValue = "";
            transKeyField1.SrcValue = null;
            transKeyField1.WhereMode = Srvtools.WhereMode.WhereOnly;
            transKeyField2.DesField = "CN_SEQ";
            transKeyField2.DesValue = null;
            transKeyField2.FieldType = null;
            transKeyField2.FieldTypeName = null;
            transKeyField2.ReadOnly = false;
            transKeyField2.SrcField = "CN_SEQ";
            transKeyField2.SrcGetValue = null;
            transKeyField2.SrcValue = null;
            transKeyField2.WhereMode = Srvtools.WhereMode.WhereOnly;
            transaction1.TransKeyFields.Add(transKeyField1);
            transaction1.TransKeyFields.Add(transKeyField2);
            transaction1.TransMode = Srvtools.TransMode.AutoAppend;
            transaction1.TransStep = 0;
            transaction1.TransTableName = "GSO_ORD_D";
            transaction1.WhenDelete = true;
            transaction1.WhenInsert = true;
            transaction1.WhenUpdate = true;
            this.trQT_QTY.Transactions.Add(transaction1);
            this.trQT_QTY.UpdateComp = this.ucDetail;
            // 
            // MasterView
            // 
            this.MasterView.CommandText = "select [PPO_PR1_M].* from [PPO_PR1_M] where CD_PO=\'1\'";
            this.MasterView.CommandTimeout = 30;
            this.MasterView.CommandType = System.Data.CommandType.Text;
            this.MasterView.EEPAlias = null;
            this.MasterView.InfoConnection = this.infoConnection;
            keyItem6.KeyName = "NO_PR";
            this.MasterView.KeyFields.Add(keyItem6);
            this.MasterView.Name = "MasterView";
            this.MasterView.NotificationAutoEnlist = false;
            this.MasterView.SecExcept = null;
            this.MasterView.SecFieldName = null;
            this.MasterView.SecStyle = Srvtools.SecurityStyle.ssByNone;
            this.MasterView.SelectTop = 0;
            this.MasterView.SiteControl = false;
            this.MasterView.SiteFieldName = null;
            this.MasterView.Transaction = null;
            this.MasterView.UpdatedRowSource = System.Data.UpdateRowSource.Both;
            ((System.ComponentModel.ISupportInitialize)(this.Master)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.infoConnection)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.Detail)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.ORD_D)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.MasterView)).EndInit();

        }
        #endregion
    }
}
